{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_radar:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Radar Plot\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let us start generating some data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "np.random.seed(3)\n",
    "\n",
    "ideal_point = np.array([0.15, 0.1, 0.2, 0.1, 0.1])\n",
    "nadir_point = np.array([0.85, 0.9, 0.95, 0.9, 0.85])\n",
    "\n",
    "F = np.random.random((1, 5)) * (nadir_point - ideal_point) + ideal_point\n",
    "print(F)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If the values should not be normalized, then we can plot the ideal and nadir point.\n",
    "This keeps the absolute values of each objective. The outer shape represents the nadir point, the inner area the ideal point. All points will lie in the area spanned by those two points additionally."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from pymoo.visualization.radar import Radar\n",
    "\n",
    "plot = Radar(bounds=[ideal_point, nadir_point], normalize_each_objective=False)\n",
    "plot.add(F)\n",
    "plot.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "But if the scale of the objective is too different, then normalization is recommended. Then, the ideal point is just the point in the middle, and the nadir point is now symmetric."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "plot = Radar(bounds=[ideal_point, nadir_point])\n",
    "plot.add(F)\n",
    "plot.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "F = np.random.random((6, 5)) * (nadir_point - ideal_point) + ideal_point\n",
    "\n",
    "plot = Radar(bounds=[ideal_point, nadir_point],\n",
    "             axis_style={\"color\": 'blue'},\n",
    "             point_style={\"color\": 'red', 's': 30})\n",
    "plot.add(F[:3], color=\"red\", alpha=0.8)\n",
    "plot.add(F[3:], color=\"green\", alpha=0.8)\n",
    "plot.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### API"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. autoclass:: pymoo.visualization.radar.Radar\n",
    "    :noindex:"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
